import { Injectable, Logger } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { Repository } from 'typeorm';
import { ConfigService } from '@nestjs/config';
import { BaseService } from '@wwjCommon/base/base.service';
import { CacheService } from '@wwjCommon/cache/cache.service';
import { LoggingService } from '@wwjCommon/logging/logging.service';
import { UploadService } from '@wwjVendor/upload/upload.service';
import { PayService } from '@wwjVendor/pay/pay.service';
import { SmsService } from '@wwjVendor/sms/sms.service';
import { NoticeService } from '@wwjVendor/notice/notice.service';

@Injectable()
export class PayService extends BaseService<any> {
  private readonly logger = new Logger(PayService.name);

  constructor(
    @InjectRepository(Object)
    protected readonly repository: Repository<any>,
    private readonly cacheService: CacheService,
    private readonly configService: ConfigService,
    private readonly loggingService: LoggingService,
    private readonly uploadService: UploadService,
    private readonly payService: PayService,
    private readonly smsService: SmsService,
    private readonly noticeService: NoticeService,
  ) {
    super(repository);
  }

  /**
   * getAuditPage
   * 对应 PHP: PayService_admin::getAuditPage()
   * 逻辑类型: undefined - undefined
   */
  async getAuditPage(where: any[]) {
    // 基于PHP真实逻辑: getAuditPage
    // PHP原文: $field = 'id, out_trade_no, type, money, body, voucher, create_time, trade_id, trade_type, status';         $search_model = $this->model->where([ [ 's...
const field = 'id, out_trade_no, type, money, body, voucher, create_time, trade_id, trade_type, status';
        const search_model = this.model.where([ [ 'site_id', '=', this.site_id ], [ 'type', '=', PayDict.OFFLINEPAY ) )).withSearch([ 'create_time', 'out_trade_no', 'status' ), where).field(field).append([ 'type_name' )).order('create_time desc'];
        return this.pageQuery(search_model);
    }

    /**
     * 获取交易详情
     * @param int id
     * @return */
    async getDetail(int id)
    {
        const field = 'id,out_trade_no,trade_type,trade_id,trade_no,body,money,voucher,status,create_time,pay_time,cancel_time,type,channel,fail_reason';
        return this.model.where([ [ 'site_id', '=', this.site_id ], [ 'id', '=', id ) ))
            .field(field)
            .append([ 'type_name', 'channel_name', 'status_name' ))
            .findOrEmpty()
            .toArray(];
    }

    /**
     * 支付审核通过
     * @param string out_trade_no
     * @return null
     */
    async pass(string out_trade_no)
    {
        return ( this.coreOfflineService ).pass(this.site_id, out_trade_no);
    }

    /**
     * 支付审核未通过
     * @param string out_trade_no
     * @param string reason
     * @return bool
     */
    async refuse(string out_trade_no, string reason)
    {
        return ( this.coreOfflineService ).refuse(this.site_id, out_trade_no, reason);
    }

    /**
     * 统计支付数据
     * @param where
     * @return int
     * @throws \think\db\exception\DbBusinessException
     */
    async payCount(where)
    {
        return this.model.where(where).count(];
    }

    /**
     * 去支付
     * @param string type
     * @param string trade_type
     * @param int trade_id
     * @param string return_url
     * @param string quit_url
     * @param string buyer_id
     * @param string voucher
     * @param string openid
     * @return mixed
     * @throws DataNotFoundBusinessException
     * @throws DbBusinessException
     * @throws ModelNotFoundBusinessException
     */
    async pay(string type, string trade_type, int trade_id, string return_url = '', string quit_url = '', string buyer_id = '', string voucher = '', string openid = '')
    {
        return ( this.corePayService ).pay(this.site_id, trade_type, trade_id, type, ChannelDict.PC, openid, return_url, quit_url, buyer_id, voucher);
    }

    /**
     * 获取支付信息
     * @param string trade_type
     * @param int trade_id
     * @return */
    async getInfoByTrade(string trade_type, int trade_id)
    {
        return ( this.corePayService ).getInfoByTrade(this.site_id, trade_type, trade_id, ChannelDict.H5);
    }

    /**
     * 获取找朋友帮忙付支付信息
     * @param string trade_type
     * @param int trade_id
     * @param string channel
     * @return * @throws DataNotFoundBusinessException
     * @throws DbBusinessException
     * @throws ModelNotFoundBusinessException
     */
    async getFriendspayInfoByTrade(string trade_type, int trade_id, string channel)
    {
        const pay_info = ( this.corePayService ).getInfoByTrade(this.site_id, trade_type, trade_id, ChannelDict.H5, PaySceneDict.FRIENDSPAY);
        if (!!pay_info)) {
            //海报
            const poster = ( this.posterService ).field('id').where([
                [ 'site_id', '=', this.site_id ],
                [ 'type', '=', 'friendspay' ],
                [ 'status', '=', 1 ],
                [ 'is_default', '=', 1 )
            )).findOrEmpty().toArray(];
            if (!!poster)) {
                pay_info[ 'poster_id' ] = poster[ 'id' ];
            }
            //发起帮付会员信息
            const member = ( this.memberService ).field('member_id,nickname,headimg').where([
                [ 'site_id', '=', this.site_id ],
                [ 'member_id', '=', pay_info[ 'from_main_id' ] )
            )).findOrEmpty().toArray(];
            pay_info[ 'member' ] = member;
            //二维码
            const qrcode = this.getQrcode(trade_type, trade_id, channel];
            pay_info[ 'link' ] = qrcode[ 'url' ];
            pay_info[ 'qrcode' ] = qrcode[ 'path' );
  }

  /**
   * getDetail
   * 对应 PHP: PayService_admin::getDetail()
   * 逻辑类型: undefined - undefined
   */
  async getDetail(id: number) {
    // 基于PHP真实逻辑: getDetail
    // PHP原文: $field = 'id,out_trade_no,trade_type,trade_id,trade_no,body,money,voucher,status,create_time,pay_time,cancel_time,type,channel,fail_reason';         r...
const field = 'id,out_trade_no,trade_type,trade_id,trade_no,body,money,voucher,status,create_time,pay_time,cancel_time,type,channel,fail_reason';
        return this.model.where([ [ 'site_id', '=', this.site_id ], [ 'id', '=', id ) ))
            .field(field)
            .append([ 'type_name', 'channel_name', 'status_name' ))
            .findOrEmpty()
            .toArray(];
    }

    /**
     * 支付审核通过
     * @param string out_trade_no
     * @return null
     */
    async pass(string out_trade_no)
    {
        return ( this.coreOfflineService ).pass(this.site_id, out_trade_no);
    }

    /**
     * 支付审核未通过
     * @param string out_trade_no
     * @param string reason
     * @return bool
     */
    async refuse(string out_trade_no, string reason)
    {
        return ( this.coreOfflineService ).refuse(this.site_id, out_trade_no, reason);
    }

    /**
     * 统计支付数据
     * @param where
     * @return int
     * @throws \think\db\exception\DbBusinessException
     */
    async payCount(where)
    {
        return this.model.where(where).count(];
    }

    /**
     * 去支付
     * @param string type
     * @param string trade_type
     * @param int trade_id
     * @param string return_url
     * @param string quit_url
     * @param string buyer_id
     * @param string voucher
     * @param string openid
     * @return mixed
     * @throws DataNotFoundBusinessException
     * @throws DbBusinessException
     * @throws ModelNotFoundBusinessException
     */
    async pay(string type, string trade_type, int trade_id, string return_url = '', string quit_url = '', string buyer_id = '', string voucher = '', string openid = '')
    {
        return ( this.corePayService ).pay(this.site_id, trade_type, trade_id, type, ChannelDict.PC, openid, return_url, quit_url, buyer_id, voucher);
    }

    /**
     * 获取支付信息
     * @param string trade_type
     * @param int trade_id
     * @return */
    async getInfoByTrade(string trade_type, int trade_id)
    {
        return ( this.corePayService ).getInfoByTrade(this.site_id, trade_type, trade_id, ChannelDict.H5);
    }

    /**
     * 获取找朋友帮忙付支付信息
     * @param string trade_type
     * @param int trade_id
     * @param string channel
     * @return * @throws DataNotFoundBusinessException
     * @throws DbBusinessException
     * @throws ModelNotFoundBusinessException
     */
    async getFriendspayInfoByTrade(string trade_type, int trade_id, string channel)
    {
        const pay_info = ( this.corePayService ).getInfoByTrade(this.site_id, trade_type, trade_id, ChannelDict.H5, PaySceneDict.FRIENDSPAY);
        if (!!pay_info)) {
            //海报
            const poster = ( this.posterService ).field('id').where([
                [ 'site_id', '=', this.site_id ],
                [ 'type', '=', 'friendspay' ],
                [ 'status', '=', 1 ],
                [ 'is_default', '=', 1 )
            )).findOrEmpty().toArray(];
            if (!!poster)) {
                pay_info[ 'poster_id' ] = poster[ 'id' ];
            }
            //发起帮付会员信息
            const member = ( this.memberService ).field('member_id,nickname,headimg').where([
                [ 'site_id', '=', this.site_id ],
                [ 'member_id', '=', pay_info[ 'from_main_id' ] )
            )).findOrEmpty().toArray(];
            pay_info[ 'member' ] = member;
            //二维码
            const qrcode = this.getQrcode(trade_type, trade_id, channel];
            pay_info[ 'link' ] = qrcode[ 'url' ];
            pay_info[ 'qrcode' ] = qrcode[ 'path' );
  }

  /**
   * pass
   * 对应 PHP: PayService_admin::pass()
   * 逻辑类型: undefined - undefined
   */
  async pass(out_trade_no: string) {
    // 基于PHP真实逻辑: pass
    // PHP原文: return ( new CoreOfflineService() )->pass($this->site_id, $out_trade_no);     }      /**      * 支付审核未通过      * @param string $out_trade_no      * @par...
return ( this.coreOfflineService ).pass(this.site_id, out_trade_no);
    }

    /**
     * 支付审核未通过
     * @param string out_trade_no
     * @param string reason
     * @return bool
     */
    async refuse(string out_trade_no, string reason)
    {
        return ( this.coreOfflineService ).refuse(this.site_id, out_trade_no, reason);
    }

    /**
     * 统计支付数据
     * @param where
     * @return int
     * @throws \think\db\exception\DbBusinessException
     */
    async payCount(where)
    {
        return this.model.where(where).count(];
    }

    /**
     * 去支付
     * @param string type
     * @param string trade_type
     * @param int trade_id
     * @param string return_url
     * @param string quit_url
     * @param string buyer_id
     * @param string voucher
     * @param string openid
     * @return mixed
     * @throws DataNotFoundBusinessException
     * @throws DbBusinessException
     * @throws ModelNotFoundBusinessException
     */
    async pay(string type, string trade_type, int trade_id, string return_url = '', string quit_url = '', string buyer_id = '', string voucher = '', string openid = '')
    {
        return ( this.corePayService ).pay(this.site_id, trade_type, trade_id, type, ChannelDict.PC, openid, return_url, quit_url, buyer_id, voucher);
    }

    /**
     * 获取支付信息
     * @param string trade_type
     * @param int trade_id
     * @return */
    async getInfoByTrade(string trade_type, int trade_id)
    {
        return ( this.corePayService ).getInfoByTrade(this.site_id, trade_type, trade_id, ChannelDict.H5);
    }

    /**
     * 获取找朋友帮忙付支付信息
     * @param string trade_type
     * @param int trade_id
     * @param string channel
     * @return * @throws DataNotFoundBusinessException
     * @throws DbBusinessException
     * @throws ModelNotFoundBusinessException
     */
    async getFriendspayInfoByTrade(string trade_type, int trade_id, string channel)
    {
        const pay_info = ( this.corePayService ).getInfoByTrade(this.site_id, trade_type, trade_id, ChannelDict.H5, PaySceneDict.FRIENDSPAY);
        if (!!pay_info)) {
            //海报
            const poster = ( this.posterService ).field('id').where([
                [ 'site_id', '=', this.site_id ],
                [ 'type', '=', 'friendspay' ],
                [ 'status', '=', 1 ],
                [ 'is_default', '=', 1 )
            )).findOrEmpty().toArray(];
            if (!!poster)) {
                pay_info[ 'poster_id' ] = poster[ 'id' ];
            }
            //发起帮付会员信息
            const member = ( this.memberService ).field('member_id,nickname,headimg').where([
                [ 'site_id', '=', this.site_id ],
                [ 'member_id', '=', pay_info[ 'from_main_id' ] )
            )).findOrEmpty().toArray(];
            pay_info[ 'member' ] = member;
            //二维码
            const qrcode = this.getQrcode(trade_type, trade_id, channel];
            pay_info[ 'link' ] = qrcode[ 'url' ];
            pay_info[ 'qrcode' ] = qrcode[ 'path' );
  }

  /**
   * refuse
   * 对应 PHP: PayService_admin::refuse()
   * 逻辑类型: undefined - undefined
   */
  async refuse(out_trade_no: string, reason: string) {
    // 基于PHP真实逻辑: refuse
    // PHP原文: return ( new CoreOfflineService() )->refuse($this->site_id, $out_trade_no, $reason);     }      /**      * 统计支付数据      * @param $where      * @return ...
return ( this.coreOfflineService ).refuse(this.site_id, out_trade_no, reason);
    }

    /**
     * 统计支付数据
     * @param where
     * @return int
     * @throws \think\db\exception\DbBusinessException
     */
    async payCount(where)
    {
        return this.model.where(where).count(];
    }

    /**
     * 去支付
     * @param string type
     * @param string trade_type
     * @param int trade_id
     * @param string return_url
     * @param string quit_url
     * @param string buyer_id
     * @param string voucher
     * @param string openid
     * @return mixed
     * @throws DataNotFoundBusinessException
     * @throws DbBusinessException
     * @throws ModelNotFoundBusinessException
     */
    async pay(string type, string trade_type, int trade_id, string return_url = '', string quit_url = '', string buyer_id = '', string voucher = '', string openid = '')
    {
        return ( this.corePayService ).pay(this.site_id, trade_type, trade_id, type, ChannelDict.PC, openid, return_url, quit_url, buyer_id, voucher);
    }

    /**
     * 获取支付信息
     * @param string trade_type
     * @param int trade_id
     * @return */
    async getInfoByTrade(string trade_type, int trade_id)
    {
        return ( this.corePayService ).getInfoByTrade(this.site_id, trade_type, trade_id, ChannelDict.H5);
    }

    /**
     * 获取找朋友帮忙付支付信息
     * @param string trade_type
     * @param int trade_id
     * @param string channel
     * @return * @throws DataNotFoundBusinessException
     * @throws DbBusinessException
     * @throws ModelNotFoundBusinessException
     */
    async getFriendspayInfoByTrade(string trade_type, int trade_id, string channel)
    {
        const pay_info = ( this.corePayService ).getInfoByTrade(this.site_id, trade_type, trade_id, ChannelDict.H5, PaySceneDict.FRIENDSPAY);
        if (!!pay_info)) {
            //海报
            const poster = ( this.posterService ).field('id').where([
                [ 'site_id', '=', this.site_id ],
                [ 'type', '=', 'friendspay' ],
                [ 'status', '=', 1 ],
                [ 'is_default', '=', 1 )
            )).findOrEmpty().toArray(];
            if (!!poster)) {
                pay_info[ 'poster_id' ] = poster[ 'id' ];
            }
            //发起帮付会员信息
            const member = ( this.memberService ).field('member_id,nickname,headimg').where([
                [ 'site_id', '=', this.site_id ],
                [ 'member_id', '=', pay_info[ 'from_main_id' ] )
            )).findOrEmpty().toArray(];
            pay_info[ 'member' ] = member;
            //二维码
            const qrcode = this.getQrcode(trade_type, trade_id, channel];
            pay_info[ 'link' ] = qrcode[ 'url' ];
            pay_info[ 'qrcode' ] = qrcode[ 'path' );
  }

  /**
   * payCount
   * 对应 PHP: PayService_admin::payCount()
   * 逻辑类型: undefined - undefined
   */
  async payCount(where: any) {
    // 基于PHP真实逻辑: payCount
    // PHP原文: return $this->model->where($where)->count();     }      /**      * 去支付      * @param string $type      * @param string $trade_type      * @param int $...
return this.model.where(where).count(];
    }

    /**
     * 去支付
     * @param string type
     * @param string trade_type
     * @param int trade_id
     * @param string return_url
     * @param string quit_url
     * @param string buyer_id
     * @param string voucher
     * @param string openid
     * @return mixed
     * @throws DataNotFoundBusinessException
     * @throws DbBusinessException
     * @throws ModelNotFoundBusinessException
     */
    async pay(string type, string trade_type, int trade_id, string return_url = '', string quit_url = '', string buyer_id = '', string voucher = '', string openid = '')
    {
        return ( this.corePayService ).pay(this.site_id, trade_type, trade_id, type, ChannelDict.PC, openid, return_url, quit_url, buyer_id, voucher);
    }

    /**
     * 获取支付信息
     * @param string trade_type
     * @param int trade_id
     * @return */
    async getInfoByTrade(string trade_type, int trade_id)
    {
        return ( this.corePayService ).getInfoByTrade(this.site_id, trade_type, trade_id, ChannelDict.H5);
    }

    /**
     * 获取找朋友帮忙付支付信息
     * @param string trade_type
     * @param int trade_id
     * @param string channel
     * @return * @throws DataNotFoundBusinessException
     * @throws DbBusinessException
     * @throws ModelNotFoundBusinessException
     */
    async getFriendspayInfoByTrade(string trade_type, int trade_id, string channel)
    {
        const pay_info = ( this.corePayService ).getInfoByTrade(this.site_id, trade_type, trade_id, ChannelDict.H5, PaySceneDict.FRIENDSPAY);
        if (!!pay_info)) {
            //海报
            const poster = ( this.posterService ).field('id').where([
                [ 'site_id', '=', this.site_id ],
                [ 'type', '=', 'friendspay' ],
                [ 'status', '=', 1 ],
                [ 'is_default', '=', 1 )
            )).findOrEmpty().toArray(];
            if (!!poster)) {
                pay_info[ 'poster_id' ] = poster[ 'id' ];
            }
            //发起帮付会员信息
            const member = ( this.memberService ).field('member_id,nickname,headimg').where([
                [ 'site_id', '=', this.site_id ],
                [ 'member_id', '=', pay_info[ 'from_main_id' ] )
            )).findOrEmpty().toArray(];
            pay_info[ 'member' ] = member;
            //二维码
            const qrcode = this.getQrcode(trade_type, trade_id, channel];
            pay_info[ 'link' ] = qrcode[ 'url' ];
            pay_info[ 'qrcode' ] = qrcode[ 'path' );
  }

  /**
   * pay
   * 对应 PHP: PayService_admin::pay()
   * 逻辑类型: undefined - undefined
   */
  async pay(type: number, trade_type: number, trade_id: number, return_url: number, quit_url: number, buyer_id: number, voucher: number, openid: number) {
    // 基于PHP真实逻辑: pay
    // PHP原文: return ( new CorePayService() )->pay($this->site_id, $trade_type, $trade_id, $type, ChannelDict::PC, $openid, $return_url, $quit_url, $buyer_id, $vouc...
return ( this.corePayService ).pay(this.site_id, trade_type, trade_id, type, ChannelDict.PC, openid, return_url, quit_url, buyer_id, voucher);
    }

    /**
     * 获取支付信息
     * @param string trade_type
     * @param int trade_id
     * @return */
    async getInfoByTrade(string trade_type, int trade_id)
    {
        return ( this.corePayService ).getInfoByTrade(this.site_id, trade_type, trade_id, ChannelDict.H5);
    }

    /**
     * 获取找朋友帮忙付支付信息
     * @param string trade_type
     * @param int trade_id
     * @param string channel
     * @return * @throws DataNotFoundBusinessException
     * @throws DbBusinessException
     * @throws ModelNotFoundBusinessException
     */
    async getFriendspayInfoByTrade(string trade_type, int trade_id, string channel)
    {
        const pay_info = ( this.corePayService ).getInfoByTrade(this.site_id, trade_type, trade_id, ChannelDict.H5, PaySceneDict.FRIENDSPAY);
        if (!!pay_info)) {
            //海报
            const poster = ( this.posterService ).field('id').where([
                [ 'site_id', '=', this.site_id ],
                [ 'type', '=', 'friendspay' ],
                [ 'status', '=', 1 ],
                [ 'is_default', '=', 1 )
            )).findOrEmpty().toArray(];
            if (!!poster)) {
                pay_info[ 'poster_id' ] = poster[ 'id' ];
            }
            //发起帮付会员信息
            const member = ( this.memberService ).field('member_id,nickname,headimg').where([
                [ 'site_id', '=', this.site_id ],
                [ 'member_id', '=', pay_info[ 'from_main_id' ] )
            )).findOrEmpty().toArray(];
            pay_info[ 'member' ] = member;
            //二维码
            const qrcode = this.getQrcode(trade_type, trade_id, channel];
            pay_info[ 'link' ] = qrcode[ 'url' ];
            pay_info[ 'qrcode' ] = qrcode[ 'path' );
  }

  /**
   * getInfoByTrade
   * 对应 PHP: PayService_admin::getInfoByTrade()
   * 逻辑类型: undefined - undefined
   */
  async getInfoByTrade(trade_type: number, trade_id: number) {
    // 基于PHP真实逻辑: getInfoByTrade
    // PHP原文: return ( new CorePayService() )->getInfoByTrade($this->site_id, $trade_type, $trade_id, ChannelDict::H5);     }      /**      * 获取找朋友帮忙付支付信息      * @p...
return ( this.corePayService ).getInfoByTrade(this.site_id, trade_type, trade_id, ChannelDict.H5);
    }

    /**
     * 获取找朋友帮忙付支付信息
     * @param string trade_type
     * @param int trade_id
     * @param string channel
     * @return * @throws DataNotFoundBusinessException
     * @throws DbBusinessException
     * @throws ModelNotFoundBusinessException
     */
    async getFriendspayInfoByTrade(string trade_type, int trade_id, string channel)
    {
        const pay_info = ( this.corePayService ).getInfoByTrade(this.site_id, trade_type, trade_id, ChannelDict.H5, PaySceneDict.FRIENDSPAY);
        if (!!pay_info)) {
            //海报
            const poster = ( this.posterService ).field('id').where([
                [ 'site_id', '=', this.site_id ],
                [ 'type', '=', 'friendspay' ],
                [ 'status', '=', 1 ],
                [ 'is_default', '=', 1 )
            )).findOrEmpty().toArray(];
            if (!!poster)) {
                pay_info[ 'poster_id' ] = poster[ 'id' ];
            }
            //发起帮付会员信息
            const member = ( this.memberService ).field('member_id,nickname,headimg').where([
                [ 'site_id', '=', this.site_id ],
                [ 'member_id', '=', pay_info[ 'from_main_id' ] )
            )).findOrEmpty().toArray(];
            pay_info[ 'member' ] = member;
            //二维码
            const qrcode = this.getQrcode(trade_type, trade_id, channel];
            pay_info[ 'link' ] = qrcode[ 'url' ];
            pay_info[ 'qrcode' ] = qrcode[ 'path' );
  }

  /**
   * getFriendspayInfoByTrade
   * 对应 PHP: PayService_admin::getFriendspayInfoByTrade()
   * 逻辑类型: undefined - undefined
   */
  async getFriendspayInfoByTrade(trade_type: number, trade_id: number, channel: number) {
    // 基于PHP真实逻辑: getFriendspayInfoByTrade
    // PHP原文: $pay_info = ( new CorePayService() )->getInfoByTrade($this->site_id, $trade_type, $trade_id, ChannelDict::H5, PaySceneDict::FRIENDSPAY);         if (!...
const pay_info = ( this.corePayService ).getInfoByTrade(this.site_id, trade_type, trade_id, ChannelDict.H5, PaySceneDict.FRIENDSPAY);
        if (!!pay_info)) {
            //海报
            const poster = ( this.posterService ).field('id').where([
                [ 'site_id', '=', this.site_id ],
                [ 'type', '=', 'friendspay' ],
                [ 'status', '=', 1 ],
                [ 'is_default', '=', 1 )
            )).findOrEmpty().toArray(];
            if (!!poster)) {
                pay_info[ 'poster_id' ] = poster[ 'id' ];
            }
            //发起帮付会员信息
            const member = ( this.memberService ).field('member_id,nickname,headimg').where([
                [ 'site_id', '=', this.site_id ],
                [ 'member_id', '=', pay_info[ 'from_main_id' ] )
            )).findOrEmpty().toArray(];
            pay_info[ 'member' ] = member;
            //二维码
            const qrcode = this.getQrcode(trade_type, trade_id, channel];
            pay_info[ 'link' ] = qrcode[ 'url' ];
            pay_info[ 'qrcode' ] = qrcode[ 'path' );
  }

  /**
   * getQrcode
   * 对应 PHP: PayService_admin::getQrcode()
   * 逻辑类型: undefined - undefined
   */
  async getQrcode(trade_type: number, trade_id: number, channel: number) {
    // 基于PHP真实逻辑: getQrcode
    // PHP原文: $url = ( new CoreSysConfigService() )->getSceneDomain($this->site_id)[ 'wap_url' ];         $page = 'app/pages/friendspay/money';          $data = [  ...
const url = ( this.coreSysConfigService ).getSceneDomain(this.site_id)[ 'wap_url' ];
        const page = 'app/pages/friendspay/money';

        const data = [
            [
                key: 'id',
                value: trade_id
            ],
            [
                key: 'type',
                value: trade_type
            ]
        ];
        const dir = 'upload/' . this.site_id  + '/friendspay_qrcode';

        const path = '';
        try {
            const path = qrcode(url, page, data, this.site_id, dir, channel);
  }

  /**
   * getPayTypeList
   * 对应 PHP: PayService_admin::getPayTypeList()
   * 逻辑类型: undefined - undefined
   */
  async getPayTypeList() {
    // 基于PHP真实逻辑: getPayTypeList
    // PHP原文: $pay_type_list = ( new CorePayService() )->getPayTypeByTrade($this->site_id, '', ChannelDict::H5);         if (!empty($pay_type_list)) {             f...
const pay_type_list = ( this.corePayService ).getPayTypeByTrade(this.site_id, '', ChannelDict.H5);
        if (!!pay_type_list)) {
            foreach (pay_type_list as k => v) {
                if (!in_[v.key, [ PayDict.BALANCEPAY, PayDict.FRIENDSPAY ))) {
                    unset(pay_type_list[ k );
  }
            const pay_type_list = array_values(pay_type_list);
  }
}
